Follow-on fix for restoring annotation on captured type wildcards - #1667
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java`:
- Around line 435-472: Add Javadoc to the non-trivial test method
wildcardCaptureRestoresConcreteAnnotatedBound, briefly documenting the
wildcard-capture regression scenario it covers and the expected diagnostic
behavior. Leave the test implementation and assertions unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c2d25661-5a50-4c3e-8453-7e0b17e9ee3f
📒 Files selected for processing (3)
nullaway/src/main/java/com/uber/nullaway/generics/TypeSubstitutionUtils.javanullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.javatest-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java
| @Test | ||
| public void wildcardCaptureRestoresConcreteAnnotatedBound() { | ||
| makeHelper() | ||
| .addSourceLines( | ||
| "Test.java", | ||
| """ | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.jspecify.annotations.Nullable; | ||
| @NullMarked | ||
| class Test { | ||
| static class Nested<T extends @Nullable Object> { | ||
| Nested<T> self() { | ||
| return this; | ||
| } | ||
| Nested<? extends @Nullable T> wildcardUpperTypeVariable() { | ||
| throw new RuntimeException(); | ||
| } | ||
| } | ||
|
|
||
| Nested<? extends String> testDirect(Nested<? extends String> receiver) { | ||
| // BUG: Diagnostic contains: incompatible types | ||
| return receiver.wildcardUpperTypeVariable(); | ||
| } | ||
|
|
||
| Nested<? extends String> testWithSelf(Nested<? extends String> receiver) { | ||
| // BUG: Diagnostic contains: incompatible types | ||
| return receiver.self().wildcardUpperTypeVariable(); | ||
| } | ||
|
|
||
| Nested<? extends String> testWithVar(Nested<? extends String> receiver) { | ||
| var local = receiver; | ||
| // BUG: Diagnostic contains: incompatible types | ||
| return local.wildcardUpperTypeVariable(); | ||
| } | ||
| } | ||
| """) | ||
| .doTest(); | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Add Javadoc for this non-trivial regression test.
Proposed fix
`@Test`
+ /** Verifies nullable bounds are restored for captured extends wildcards across receiver paths. */
public void wildcardCaptureRestoresConcreteAnnotatedBound() {As per coding guidelines, “Add Javadoc to every non-trivial method, including private methods.”
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @Test | |
| public void wildcardCaptureRestoresConcreteAnnotatedBound() { | |
| makeHelper() | |
| .addSourceLines( | |
| "Test.java", | |
| """ | |
| import org.jspecify.annotations.NullMarked; | |
| import org.jspecify.annotations.Nullable; | |
| @NullMarked | |
| class Test { | |
| static class Nested<T extends @Nullable Object> { | |
| Nested<T> self() { | |
| return this; | |
| } | |
| Nested<? extends @Nullable T> wildcardUpperTypeVariable() { | |
| throw new RuntimeException(); | |
| } | |
| } | |
| Nested<? extends String> testDirect(Nested<? extends String> receiver) { | |
| // BUG: Diagnostic contains: incompatible types | |
| return receiver.wildcardUpperTypeVariable(); | |
| } | |
| Nested<? extends String> testWithSelf(Nested<? extends String> receiver) { | |
| // BUG: Diagnostic contains: incompatible types | |
| return receiver.self().wildcardUpperTypeVariable(); | |
| } | |
| Nested<? extends String> testWithVar(Nested<? extends String> receiver) { | |
| var local = receiver; | |
| // BUG: Diagnostic contains: incompatible types | |
| return local.wildcardUpperTypeVariable(); | |
| } | |
| } | |
| """) | |
| .doTest(); | |
| } | |
| `@Test` | |
| /** Verifies nullable bounds are restored for captured extends wildcards across receiver paths. */ | |
| public void wildcardCaptureRestoresConcreteAnnotatedBound() { | |
| makeHelper() | |
| .addSourceLines( | |
| "Test.java", | |
| """ | |
| import org.jspecify.annotations.NullMarked; | |
| import org.jspecify.annotations.Nullable; | |
| `@NullMarked` | |
| class Test { | |
| static class Nested<T extends `@Nullable` Object> { | |
| Nested<T> self() { | |
| return this; | |
| } | |
| Nested<? extends `@Nullable` T> wildcardUpperTypeVariable() { | |
| throw new RuntimeException(); | |
| } | |
| } | |
| Nested<? extends String> testDirect(Nested<? extends String> receiver) { | |
| // BUG: Diagnostic contains: incompatible types | |
| return receiver.wildcardUpperTypeVariable(); | |
| } | |
| Nested<? extends String> testWithSelf(Nested<? extends String> receiver) { | |
| // BUG: Diagnostic contains: incompatible types | |
| return receiver.self().wildcardUpperTypeVariable(); | |
| } | |
| Nested<? extends String> testWithVar(Nested<? extends String> receiver) { | |
| var local = receiver; | |
| // BUG: Diagnostic contains: incompatible types | |
| return local.wildcardUpperTypeVariable(); | |
| } | |
| } | |
| """) | |
| .doTest(); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java` around
lines 435 - 472, Add Javadoc to the non-trivial test method
wildcardCaptureRestoresConcreteAnnotatedBound, briefly documenting the
wildcard-capture regression scenario it covers and the expected diagnostic
behavior. Leave the test implementation and assertions unchanged.
Source: Coding guidelines
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1667 +/- ##
=========================================
Coverage 87.66% 87.67%
Complexity 3138 3138
=========================================
Files 109 109
Lines 10614 10619 +5
Branches 2145 2147 +2
=========================================
+ Hits 9305 9310 +5
Misses 628 628
Partials 681 681 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1de4d06 to
4c228f2
Compare
1eeae57 to
78d77c1
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java (1)
410-411: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAdd Javadoc to both new regression tests.
Both methods test captured wildcard annotation restoration. Add a short Javadoc comment that states the tested contract.
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java#L410-L411: document nested-nullability restoration on a captured wildcard return.test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java#L572-L573: document modeled nullable-bound restoration across receiver paths.As per coding guidelines, “Add Javadoc to every non-trivial method, including private methods.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java` around lines 410 - 411, Add short Javadoc comments to both regression test methods: nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java:410-411 should document nested-nullability restoration on a captured wildcard return, and test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java:572-573 should document modeled nullable-bound restoration across receiver paths.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java`:
- Around line 410-411: Add short Javadoc comments to both regression test
methods:
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java:410-411
should document nested-nullability restoration on a captured wildcard return,
and
test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java:572-573
should document modeled nullable-bound restoration across receiver paths.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6bc57294-119d-4b91-9712-959960df12f2
📒 Files selected for processing (3)
nullaway/src/main/java/com/uber/nullaway/generics/TypeSubstitutionUtils.javanullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.javatest-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java
4c228f2 to
2449fdd
Compare
78d77c1 to
f872e52
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java (1)
410-433: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAdd Javadoc to the new regression test methods.
These methods contain compiler regression fixtures and are non-trivial. Add Javadoc that states the regression condition and expected analysis result.
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java#L410-L433: Document the captured wildcard return with nested nullable type arguments.nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java#L1209-L1237: Document the accepted reactive response pipeline from issue 1671.test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java#L572-L620: Document modeled captured wildcard bounds across direct, chained, and local receiver paths.Proposed Javadoc
diff --git a/nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java b/nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java @@ + /** Verifies nested nullable type arguments are retained on a captured wildcard return. */ `@Test` public void wildcardCaptureReturnPreservesNestedNullability() { @@ + /** Verifies JSpecify analysis accepts the reactive response pipeline from issue 1671. */ `@Test` public void issue1671() { diff --git a/test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java b/test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java @@ + /** Verifies modeled nullable bounds on captured wildcards across receiver paths. */ `@Test` public void nestedWildcardWithCapturedTypeVariableBound() {As per coding guidelines, “Add Javadoc to every non-trivial method, including private methods.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java` around lines 410 - 433, Add Javadoc describing the regression condition and expected analysis result for the test method at nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java:410-433, specifically captured wildcard returns with nested nullable type arguments. Also document the accepted reactive response pipeline test at nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java:1209-1237 and the modeled captured wildcard bounds across direct, chained, and local receiver paths in nullaway/test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java:572-620; do not alter test behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java`:
- Around line 410-433: Add Javadoc describing the regression condition and
expected analysis result for the test method at
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java:410-433,
specifically captured wildcard returns with nested nullable type arguments. Also
document the accepted reactive response pipeline test at
nullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.java:1209-1237
and the modeled captured wildcard bounds across direct, chained, and local
receiver paths in
nullaway/test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java:572-620;
do not alter test behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 26ce5419-b6c5-4d59-beb6-4eff303b0dde
📒 Files selected for processing (3)
nullaway/src/main/java/com/uber/nullaway/generics/TypeSubstitutionUtils.javanullaway/src/test/java/com/uber/nullaway/jspecify/WildcardTests.javatest-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java
2449fdd to
6ea8dce
Compare
f872e52 to
4794e3f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
The fix in #1666 missed a case that has impacts outside of library models as well. See the new test
WildcardTests.annotationRestoredFromUpperBoundToCapturedWildcard. ThetestWithSelfcase was handled before, but nottestDirectortestWithVar.Summary by CodeRabbit
Bug Fixes
Tests